 <form id="rolesform" action="index.php?ctl=roles&act=edit&p[0]=<{$roles.role_id}>" method="POST">
		<div style="text-align:right;padding:3px 18px"><{help docid="101" type="link"}><{t}>点击查看帮助<{/t}><{/help}></div>
		<input type="hidden" name="role_id" value="<{$roles.role_id}>" />
		<div class="division">
				<span style="font-weight:bold;"><{t}>角色名称<{/t}></span>

       	<input style="margin-left:10px;" type="text" vtype="required" name="role_name" value="<{$roles.role_name}>" class="x-input " autocomplete="off">
		<!--add by peter 2017-03-24 增加属性是否总部角色-->
		<span style="margin-left:30px;font-weight:bold"><{t}>总部角色<{/t}></span>
		<input style="margin-left:10px;position:relative;top:3px;" class="" type="checkbox" name="super" value="1" <{if $roles.super eq 1}>checked="checked"<{/if}>>
       </div>


		<!--add by peter 2017-03-24 增加属性办事处的选择-->
		<div class='division'>
		<h4><{t}>所属办事处<{/t}></h4>
		<{$menus4}>
		</div>

       	   <div class='division'>
		  <h4><{t}>角色权限<{/t}></h4>
		 <input type='hidden'  vtype='requiredcheckbox'/>
<{$menus1}><!-- 桌面挂件权限 -->

<{$menus2}><!-- 控制面板权限 -->

<div>
<input class='parent'<{if $checked_all}> checked="checked"<{/if}> type="checkbox">全选(业务权限)
<{foreach from=$menus3 item=value}>
<{$value}>
<{/foreach}>
</div>
</div>
</form>

<{area inject=".mainFoot"}>
		<div class="table-action">
                   <{button label=$___desktop="确定"|t:'desktop' id="rolesform-submit" class="btn-primary"}>
	   </div>
<{/area}>
<script>
function nameCheck(input){
	id = input.value;
	role_id = $('roleID').value;
    if((input.checked)){
        new Request.HTML({
		url:'index.php?app=desktop&ctl=roles&act=get_permission',method:'post',
		update:$(input).getNext(),data:'role_id='+role_id+'&name='+encodeURIComponent(input.value=input.value.trim())}).send();
        $('workground'+id).setStyle('display','block');
    }
    else{
        $('workground'+id).setStyle('display','none').empty();;
    }

}

</script>
<script>
(function(){
    var _form = $('rolesform');
    var btn =$('rolesform-submit');
    var finder = finderGroup['<{$env.get.finder_id}>'];

    _form.store('target',{
        onComplete:function(){
            try{
                var _dialogIns = btn.getParent('.dialog').retrieve('instance');
             }catch(e){}
            if(_dialogIns){
                _dialogIns.close();
                finder.refresh.delay(400,finder);
            }


        }

    });

        btn.addEvent('click',function(){

            _form.fireEvent('submit',{stop:$empty});



        });


    _form.getElements('input.parent').addEvent('change',function(e){
        this.getParent().getElements('ul li input[type=checkbox]').set('checked',this.checked);
	//add by peter issue 189
	if (this.getAttribute('pid')){officeCheckCtrl(this.getAttribute('pid'));}
    });
 	//add by peter 2017-05-08 issue 189 不全选控制	
	_form.getElements('input[name=office[]]').addEvent('change',function(e){
		officeCheckCtrl(this.getAttribute('pid'));
	});
	function officeCheckCtrl(pid){
		var es1=_form.getElements('input[pid='+pid+']');
		for (var i=0; i<es1.length; i++){
			if (!es1[i].checked){
				var pe1=_form.getElement('input[myid='+pid+']');
				pe1.checked=false;
				if (pe1.getAttribute('pid')==0){
					_form.getElement('input[myid=0]').checked=false;
					break;
				}
				else{
					officeCheckCtrl(pe1.getAttribute('pid'));
				}
			}
		}	
	}

    (function(){
        _form.getElements('input[checked]').each(function(el){
            if(!el.checked)el.set('checked', true);
        });
    }).delay(0);
})();



</script>
